import Mock from 'mockjs'
const Random = Mock.Random

export const messageList = (params) => {
  let list = []

  doCustomTimes(1, () => {
    list.push(Mock.mock({
      'guid': Random.guid(),
      'id': Random.id(),
      'event_msg': Random.ctitle(3, 7),
      'pic_url': Random.image('250x140', '#bbb', '#fff', 'jpg', '报警图片'),
      'name': Random.pick(['高温报警', '周界报警']),
      'created_at': Random.now('second')
    }))
  })

  return list
}

/**
 * @param {Number} times 回调函数需要执行的次数
 * @param {Function} callback 回调函数
 */
export const doCustomTimes = (times, callback) => {
  let i = -1
  while (++i < times) {
    callback(i)
  }
}
